package com.example.demo.controller.conllection;

import com.example.demo.model.ResponseData;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hanqiang
 * @Classname RemoveCollectionController
 * @Date 2020/10/5 15:05
 * @Description:
 */
@RestController
@RequestMapping("/collection")
public class RemoveCollectionController {
    @Autowired
    MongoTemplate mongoTemplate;

    @ApiOperation(value="删除集合",notes="删除集合")
    @PostMapping("/removeCollection")
    public ResponseData removeCollection(){
        String collectionName="shops";
        mongoTemplate.dropCollection(collectionName);
        return ResponseData.success(mongoTemplate.collectionExists(collectionName));
    }
}
